'''
# 斐波那契数列
def fb(n):
    if n <= 1:
        return n  # 结果
    else:
        return fb(n-1)+fb(n-2)

for i in range(1,10):
    print(fb(i),end=' ')
'''
''' 
# 闭包
def out():
    n = 1
    def inner():
        n+=1
    return inner
print(out())
'''
'''
# 装饰器计算程序耗时
import time
def out(func):
    def inner():
        s = time.time()
        func()
        e = time.time()
        print('该程序运行了',e-s,'秒')
    return inner

@out
def test():
    for i in range(1000000):
        pass
test()
'''

'''
# 模拟udp
import socket
udp = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)  # 创建
udp.sendto("在吗？".encode("gbk"),("192.168.43.62",8080))  # 发送
recv_data,ip_port = udp.recvfrom(1024)  # 接收响应
print(recv_data.decode("gbk"))
udp.close()   # 关闭


# 模拟tcp
import socket
tcp_server = socket.socket()  #  创建tcp服务端套接字
tcp_server.bind(("",8080)) # 绑定
tcp_server.listen(128)  # 设置监听，将主动套接字变为被动套接字，并设置单线程下最多等待连接数
tcp_client,ip_port = tcp_server.accept()  # 等待接收链接
tcp_client.send("在吗？".encode("gbk"))  # 数据通信
print(tcp_client.recv(4096).decode("gbk"))
tcp_client.close() # 关闭
tcp_server.close()
'''